<html>
<head><meta charset="utf-8"><title>jobserver · t-compiler/wg-parallel-rustc · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/index.html">t-compiler/wg-parallel-rustc</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/jobserver.html">jobserver</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="179356053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/jobserver/near/179356053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/jobserver.html#179356053">(Oct 29 2019 at 18:00)</a>:</h4>
<p>We'd want a custom jobserver protocol which can share tokens equally between processes. We want the jobserver to be able to ask processes to give back tokens when new processes are spawned. We'd also want cargo to reserve tokens if it wants to spawn a number of rustc instances so it knows each can get one.</p>
<p>For Rayon, it would be helpful if we could spawn threads one at a time. So a thread spawns, it blocks on a jobserver token, once it gets it, it spawns the next thread and so on. Once rustc is done, we want to be able to exit without waiting for all the threads to spawn and then terminate.</p>
<p>One thing to note is that unlike regular Rayon, only threads which are not waiting on a jobserver token will wake up when there's more work. So if jobserver tokens are spread more equally between processes you won't see the behavior where Rayon wakes up all the threads. If there's just a few rustc processes you can still get issues with the jobserver tokens shuffling between processes. Hopefully those can be fixed by making sure there's more work to be done in parallel, adding more idling time before falling asleep and using fibers / stackful coroutines to avoid blocking on queries.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>